import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

/// 添加了默认图片的网络加载图
class ImageNetwork extends StatelessWidget {
  final String url;
  final double width;
  final double height;
  final BoxFit fit;

  const ImageNetwork({
    Key key,
    @required this.url,
    this.width,
    this.height,
    this.fit = BoxFit.fill,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CachedNetworkImage(
      imageUrl: '$url',
      errorWidget: (context, url, error) => Image.asset(
        "assets/image/logo_demo.png",
        width: width,
        height: height,
        fit: fit,
      ),
      width: width,
      height: height,
      fit: fit,
    );
  }
}
